//http://192.168.22.8/003ajax/service/getWeather01.php?province=江苏省&city=南京市
window.onload=function(){
    $.ajax({
        url:"http://192.168.22.8:81/getWeather01.php?province=江苏省&city=南京市",
        type:"post",
        dataType:"json",
        // data:{id:1}
    }).done((result)=>{
        console.log("result:",result);
        var observe=result.data.observe;
        wind_direction1=result.data.forecast_1h[0].wind_direction;//
        observe.wind_direction1=wind_direction1;
        observe["晴天"]=result.data.tips.observe["0"];
        observe["非晴天"]=result.data.tips.observe["1"];
        console.log(observe);
        var topleft = template("template1", observe);
        $(".topleft").html(topleft);
        var forecast_1h=result.data.forecast_1h;
        var rise=result.data.rise;

        for(var key in forecast_1h){
            var time=forecast_1h[key].update_time.substring(8,10);
            var today=forecast_1h[key].update_time.substring(0,8);
            forecast_1h[key]["time"]=time;
            for(var key1 in rise){
                var today1=rise[key1].time;
                // console.log("today:"+today)
                // console.log("today1:"+today1);
                // console.log();
                if(today==today1){
                    forecast_1h[key]["sunrise"]=rise[key1].sunrise;
                    forecast_1h[key]["sunset"]=rise[key1].sunset;
                }
            }
        }
        console.log(forecast_1h);
        var one_hour_detail=template("template2",{forecast_1h});
        $(".one_hour_detail1").html(one_hour_detail);

    });
}